#include <stdio.h>
#include <limits.h>

#define Max(a,b) ((a)>(b)?(a):(b))

double findMaxAverage(int* nums, int numsSize, int k) {
    long sum=0,max=LONG_MIN;
    for( int i=0; i < numsSize; i++ ){
        if( i < k-1 ){
            sum+=nums[i];
            continue;
        }
        sum+=nums[i];
        max=Max(max,sum);
        sum-=nums[ i-k+1 ];
    }
    return (double)max/k;
}

int main(){
    int nums[]={1,12,-5,-6,50,3};
    printf("%lf\n",findMaxAverage(nums,sizeof(nums)/sizeof(int),4));
    return 0;
}
